<template>
	<view style="margin-top: 150rpx;">
		<view class="column-css" style="padding: 20rpx 10rpx;">
			<view class="row-css" style="margin-top: 20rpx;">
				<view style="align-items: center;"><checkbox :checked="ischeckbox" style="transform:scale(0.7)" @click="checkbox()"></checkbox></view>
				<view style="font-size: 30rpx;margin-top: 5rpx;"><text>取消对运易通科技有限公司获取本人位置信息及轨迹信息的授权，确认提交后生效。</text></view>
			</view>
			<view class="row-css" style="padding:0 20rpx;margin-top: 20rpx;text-align: center;">
				<view class="row-css" style="width: 260rpx;align-items: center;justify-content: flex-end;">声明人姓名：</view>
				<view style="width: 360rpx;"><input class="input-code" style="360rpx" type="text" placeholder="声明人姓名" v-model="name" /></view>
			</view>
			<view class="row-css" style="padding:0 20rpx;margin-top: 20rpx;text-align: center;">
				<view class="row-css" style="width: 260rpx;align-items: center;justify-content: flex-end;">声明人手机号码：</view>
				<view style="width: 360rpx;"><input class="input-code" type="number" maxlength="11" placeholder="声明人手机号码" v-model="phone" /></view>
			</view>

			<view class="row-css" style="justify-content: flex-end; width: 620rpx; padding:0 20rpx;margin-top: 20rpx;text-align: right;">
				<input class="input-code" style="width: 320rpx;" type="code" maxlength="6" onkeyup="this.value=this.value.replace(/\D/g,'')" placeholder="验证码" v-model="code" />
				<view class="code-view" @click="sendcode">
					<text style="text-align: center;">{{ codeText }}</text>
				</view>
			</view>
			<view class="row-css" style="align-items: center;justify-content: center;margin-top: 20rpx;">
				<view class="code-view" style="background: #FB8536;align-items: center;margin: 30rpx; padding: 20rpx;" @click="sendcode">
					<text style="text-align: center;">确认提交</text>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
export default {
	data() {
		return {
			ischeckbox: false,
			time: 60,
			codeText: '获取验证码',
			name: '',
			phone: '',
			code: ''
		};
	},
	methods: {
		checkbox: function() {
			this.ischeckbox = !this.ischeckbox;
		},
		sendcode() {
			if (this.time == 60) {
				// this.projectCode = Math.floor(Math.random() * 1259);
				this.timer = setInterval(() => {
					this.codeText = `${this.time}s后获取验证码`;
					this.time--;
					if (this.time < 0) {
						this.time = 60;
						this.codeText = '获取验证码';
						clearInterval(this.timer);
					}
				}, 1000);
				this.wxRequest({
					url: `${this.API}/driverLocation/sendmsg?auth_type=1&tel=` + this.phone,
					method: 'POST',
					title: '加载中...',
					success: res => {
						uni.showToast({
							title: '验证码已发送',
							icon: 'none'
						});
					}
				});
			}
		},
		autohoir() {
			if (this.ischeckbox) {
				if (this.name && this.phone) {
					this.wxRequest({
						url: `${this.API}/driverLocation/agreeauth?auth_status=false&tel=` + this.phone + '&code=' + this.code,
						method: 'POST',
						success: res => {
							uni.showToast({
								title: '取消授权成功！',
								icon: 'none'
							});
							uni.navigateBack({
								delta: 3
							});
						}
					});
				} else {
					uni.showToast({
						title: '请完善相关信息！',
						icon: 'none'
					});
				}
			} else {
				uni.showToast({
					title: '请勾选并查看相关取消授权影响！',
					icon: 'none'
				});
			}
		}
	}
};
</script>

<style>
page {
	background-color: #ffffff;
	height: 100%;
	padding: 20rpx 10rpx;
	font-size: 32rpx;
	line-height: 1.3;
}

.row-css {
	display: flex;
	flex-direction: row;
}

.column-css {
	display: flex;
	flex-direction: column;
}

.code-view {
	width: 140rpx;
	text-align: center;
	padding: 12rpx 0;
	background: #ffffff;
	border: 1rpx solid #eeeeee;
	border-radius: 5rpx;

	width: 200rpx;
	text-align: center;
	font-size: 24rpx;
	margin-left: 20rpx;
	color: #ffffff;
	background: #2979ff;
	border-radius: 2rpx;
	padding: 15rpx 0;
}

.input-code {
	text-align: center;
	padding: 12rpx 0;
	background: #ffffff;
	border: 1rpx solid #eeeeee;
	border-radius: 2rpx;
}
</style>
